<template>
  <div class="relative w-full">
    <div class="page-header">
      <img alt="多信息融合柑橘智慧大棚" class="title" src="@/assets/images/header-title.png" />

      <!--    <div class="left main-text-color">-->
      <!--      <div class="">{{ currentTime.format('YYYY-MM-DD') }}</div>-->
      <!--      <div class="clock-font text-[24px]">{{ currentTime.format('HH:mm:ss') }}</div>-->
      <!--    </div>-->
      <!--    <div class="title flex-1 flex justify-center flex-col items-center">-->
      <!--      <div class="text-center">花园智慧农业云平台</div>-->
      <!--      <dv-decoration5 :dur="2" style="width: 60vw; height: 40px" />-->
      <!--    </div>-->

      <!--    <div class="right flex items-center main-text-color">-->
      <!--      <div class="mx-2">{{ weekDays[Number(currentTime.format('d'))] }}</div>-->
      <!--      <div class="mx-2">{{ todayWeather.weather }}</div>-->
      <!--      <div class="mx-2 clock-font">{{ todayWeather.temperature }}℃</div>-->
      <!--    </div>-->
    </div>
    <img alt="" class="bg2" src="@/assets/images/header-bg2.png" />
  </div>
</template>

<script lang="ts" setup>
  import { ref } from 'vue'
  import dayjs from 'dayjs'

  // 日期相关
  const currentTime = ref(dayjs())
  const weekDays = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六']
  const updateTime = () => {
    // 一秒钟更新一次
    setInterval(() => {
      currentTime.value = dayjs()
    }, 1000)
  }
  updateTime()

  // 天气相关
  const todayWeather = ref<any>({ weather: '', temperature: '' })
  const getWeather = () => {
    //加载天气查询插件
    AMap.plugin('AMap.Weather', function () {
      //创建天气查询实例
      const weather = new AMap.Weather()
      //执行实时天气信息查询
      weather.getLive('余姚市', function (err: any, data: any) {
        console.log(err, data, '天气信息')
        if (err) return
        todayWeather.value = data
      })
    })
  }
  // getWeather()
</script>

<style lang="scss" scoped>
  .page-header {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 24px;
    height: 100px;
    width: 100%;
    background: url('@/assets/images/header-bg.png') no-repeat top left;
    background-size: 100% 100%;
    z-index: 100;
    .title {
      position: relative;
      width: 660px;
      z-index: 100;
      //height: 54px;
    }
  }
  .bg2 {
    position: absolute;
    top: 20px;
    left: 50%;
    width: 80%;
    transform: translateX(-50%);
    z-index: 0;
  }
</style>
